package com.cole.miniapp.project.controller;

import com.cole.miniapp.common.bean.ResponseResult;
import com.cole.miniapp.project.annotation.LoginStore;
import com.cole.miniapp.project.domain.FcmBusiness;
import com.cole.miniapp.project.domain.FcmUserConsumption;
import com.cole.miniapp.project.enumeration.store.StoreOrderStateEmun;
import com.cole.miniapp.project.enumeration.store.StoreOrderTypeEmun;
import com.cole.miniapp.project.mapper.FcmUserConsumptionMapper;
import com.cole.miniapp.project.service.PayService;
import com.cole.qrcode.QrcodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
import java.util.UUID;

/**
 * @Author: Ceanie
 * @Despriction:
 * @Date: Created in 18:00 2019-05-19
 * @Modify By: 二维码控制器
 **/

@RestController
@RequestMapping(value = "/api/qrcode")
public class QrcodeController {

    @Autowired
    private PayService payService;

    /**
     * 门店员工生成收款码
     * @param fcmBusiness
     * @param money
     * @return
     */
    @PostMapping(value = "/createPaymentCode")
    public ResponseResult createPaymentCode(@LoginStore FcmBusiness fcmBusiness,
                                            @RequestParam(value = "money") BigDecimal money,
                                            @RequestParam(value = "formId") String formId) {
        ResponseResult result=ResponseResult.success();

        String path=payService.createPaymentCode(fcmBusiness,money,formId);
        //返回图片路径
        result.setData(path);
        return result;
    }
}
